# name : broom+dplyer, grouped modeling
# key : broom_nest_modeling
# contributor: Shuguang Sun
# --
${1:model} <- ${2:inds} |>
  tidyr::nest(data = -${3:groupvar}) |>
  dplyr::mutate(
    fit = purrr::map(data, ~ lm(wt ~ mpg + qsec + gear, data = .x)),
    tidied = purrr::map(fit, tidy),
    glanced = purrr::map(fit, glance),
    augmented = purrr::map(fit, augment)
  )

$1 |>
  tidyr::unnest(tidied)